package com.yyjj.hangqing.activity;

import android.os.Bundle;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.aries.ui.view.title.TitleBarView;
import com.vise.xsnow.http.ViseHttp;
import com.vise.xsnow.http.callback.ACallback;
import com.yyjj.hangqing.R;
import com.yyjj.hangqing.api.Api;
import com.yyjj.hangqing.entity.BaseTResp;
import com.yyjj.hangqing.entity.ZhiShuBaoDetailEntity;
import com.yyjj.hangqing.entity.ZhiShuBaoEntity;

import java.util.ArrayList;

import tech.com.commoncore.app.FastManager;
import tech.com.commoncore.base.BaseTitleActivity;
import tech.com.commoncore.constant.ApiConstant;

@Route(path = "/hq/ZhiShuBaoDetail")
public class ZhiShuBaoDetailActivity extends BaseTitleActivity {
    public static final String CODE = "symbol";
    private String symbol;
    private android.widget.TextView tvUnitPrevsettlement;
    private android.widget.TextView tvCumulative;
    private android.widget.TextView tvMonth;
    private android.widget.TextView tvOneYear;
    private android.widget.TextView tvThreeMonth;
    private android.widget.TextView tvThreeYear;
    private android.widget.TextView tvSixMonth;
    private android.widget.TextView tvEstablished;
    private android.widget.TextView tvQc;
    private android.widget.TextView tvSymbol;
    private android.widget.TextView tvType;
    private android.widget.TextView tvEstablishmentDate;
    private android.widget.TextView tvScale;
    private android.widget.TextView tvExecutive;
    private android.widget.TextView tvManager;
    private android.widget.TextView tv_zde;
    TitleBarView titleBar;
    @Override
    public void setTitleBar(TitleBarView titleBar) {
        this.titleBar = titleBar;
    }

    @Override
    public int getContentLayout() {
        return R.layout.hq_activity_zhi_shu_bao_detail;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
//        https://d.wanjinig.cn/new_api/Funs/detail?is_cache=0&symbol=001632

        symbol = getIntent().getStringExtra(CODE);

//        tvName = (TextView) findViewById(R.id.tv_name);
        tvUnitPrevsettlement = (TextView) findViewById(R.id.tv_unit_prevsettlement);
        tvCumulative = (TextView) findViewById(R.id.tv_cumulative);
        tvMonth = (TextView) findViewById(R.id.tv_month);
        tvOneYear = (TextView) findViewById(R.id.tv_one_year);
        tvThreeMonth = (TextView) findViewById(R.id.tv_three_month);
        tvThreeYear = (TextView) findViewById(R.id.tv_three_year);
        tvSixMonth = (TextView) findViewById(R.id.tv_six_month);
        tvEstablished = (TextView) findViewById(R.id.tv_established);
        tvQc = (TextView) findViewById(R.id.tv_qc);
        tvSymbol = (TextView) findViewById(R.id.tv_symbol);
        tvType = (TextView) findViewById(R.id.tv_type);
        tvEstablishmentDate = (TextView) findViewById(R.id.tv_establishment_date);
        tvScale = (TextView) findViewById(R.id.tv_scale);
        tvExecutive = (TextView) findViewById(R.id.tv_executive);
        tvManager = (TextView) findViewById(R.id.tv_manager);
        tv_zde = (TextView) findViewById(R.id.tv_zde);

        showLoading();
        ViseHttp.GET(Api.ZHISHUBAO_DETAIL_URL)
                .baseUrl(ApiConstant.BASE_URL)
                .addParam("is_cache","0")
                .addParam("symbol",symbol)
                .request(new ACallback<BaseTResp<ZhiShuBaoDetailEntity>>() {
                    @Override
                    public void onSuccess(BaseTResp<ZhiShuBaoDetailEntity> data) {
                        if(data.code ==1 && data.data != null){
                            titleBar.setTitleMainText(data.data.getName());
//                            tvName.setText(data.data.getName());
                            tvUnitPrevsettlement.setText(data.data.getUnit_prevsettlement());

                            tvCumulative.setText(data.data.getCumulative());
                            tvMonth.setText(data.data.getMonth());
                            tvOneYear.setText(data.data.getOne_year());
                            tvThreeMonth.setText(data.data.getThree_month());

                            tvThreeYear.setText(data.data.getThree_year());
                            tvSixMonth.setText(data.data.getSix_month());
                            tvEstablished  .setText(data.data.getEstablished());
                            tvQc.setText(data.data.getName());
//                            tvJc.setText(data.data.getName());
                            tvSymbol.setText(data.data.getSymbol());
                            tvType.setText(data.data.getType());
                            tvEstablishmentDate.setText(data.data.getEstablishment_date());
                            tvScale.setText(data.data.getScale());
                            tvExecutive.setText(data.data.getExecutive());
                            tvManager.setText(data.data.getManager());
                            tv_zde.setText(data.data.getPrevsettlement());


                            hideLoading();
                        }
                    }

                    @Override
                    public void onFail(int errCode, String errMsg) {
                        hideLoading();
                    }
                });

    }

}
